package com.hkw.utils;

import com.hkw.model.ClassRoom;
import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * ResultSetHandler的实现类，将查询到的结果集封装成ClassRoom
 */
public class ClassRoomHandler implements ResultSetHandler<ClassRoom> {
    ClassRoom classRoom = null;
    @Override
    public ClassRoom handle(ResultSet resultSet) throws SQLException {
        while(resultSet.next()) {
            classRoom = new ClassRoom();
            classRoom.setId(resultSet.getInt("id"));
            classRoom.setClassTeaName(resultSet.getString("classTeaName"));
            classRoom.setGrade(resultSet.getString("grade"));
            classRoom.setName(resultSet.getString("name"));
            classRoom.setNumber(resultSet.getInt("number"));
            classRoom.setSlogan(resultSet.getString("slogan"));
        }
        return classRoom;
    }
}
